package com.csgsystems.im.survey;

import java.io.Serializable;

public class Survey implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 4421313811323056192L;
	
	private Long id = null;
	private String name = null;
	private int categoryId = 0;
	private long hierarchyItemId = 0L;
	private String vxml = null;
	private int numberOfQuestions = 0;
	private int voiceRecording = 0;
	
	private SurveyType type = null;
	private SurveyStatus status = null;
	
	private boolean resultFollowup = false;
	private boolean displayResultAverage = false;
	
	public Survey() {
		
	}
	
	public Survey(String name, Category category, long hierarchyItemId, 
			String vxml, int numberOfQuestions, int voiceRecording, 
			SurveyType type, boolean resultFollowUp, boolean displayResultAverage, 
			SurveyStatus status) {
		this();
		
		// Validation of the incoming fields to be done.
		this.name = name;
		this.categoryId = category.getId();
		this.hierarchyItemId = hierarchyItemId;
		this.vxml = vxml;
		this.numberOfQuestions = numberOfQuestions;
		this.voiceRecording = voiceRecording;
		this.type = type;
		this.status = SurveyStatus.Active;
		this.resultFollowup = resultFollowUp;
		this.displayResultAverage = displayResultAverage;
		this.status = status;
		
	}
	
	public Survey(String name, int categoryId, long hierarchyItemId, 
			String vxml, int numberOfQuestions, int voiceRecording, 
			SurveyType type, boolean resultFollowUp, boolean displayResultAverage, 
			SurveyStatus status) {
		this();
		
		// Validation of the incoming fields to be done.
		this.name = name;
		this.categoryId = categoryId;
		this.hierarchyItemId = hierarchyItemId;
		this.vxml = vxml;
		this.numberOfQuestions = numberOfQuestions;
		this.voiceRecording = voiceRecording;
		this.type = type;
		this.status = SurveyStatus.Active;
		this.resultFollowup = resultFollowUp;
		this.displayResultAverage = displayResultAverage;
		this.status = status;
		
	}
	

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getCategoryId() {
		return categoryId;
	}

	public void setCategoryId(int categoryId) {
		this.categoryId = categoryId;
	}

	public long getHierarchyItemId() {
		return hierarchyItemId;
	}

	public void setHierarchyItemId(long hierarchyItemId) {
		this.hierarchyItemId = hierarchyItemId;
	}

	public String getVxml() {
		return vxml;
	}

	public void setVxml(String vxml) {
		this.vxml = vxml;
	}

	public int getNumberOfQuestions() {
		return numberOfQuestions;
	}

	public void setNumberOfQuestions(int numberOfQuestions) {
		this.numberOfQuestions = numberOfQuestions;
	}

	public int getVoiceRecording() {
		return voiceRecording;
	}

	public void setVoiceRecording(int voiceRecording) {
		this.voiceRecording = voiceRecording;
	}

//	public Set<String> getTypes() {
//		return types;
//	}
//
//	public void setTypes(Set<String> types) {
//		this.types = types;
//	}

	public SurveyType getType() {
		return type;
	}

	public void setType(SurveyType type) {
		this.type = type;
	}

	public SurveyStatus getStatus() {
		return status;
	}

	public void setStatus(SurveyStatus status) {
		this.status = status;
	}

	public boolean isResultFollowup() {
		return resultFollowup;
	}

	public void setResultFollowup(boolean resultFollowup) {
		this.resultFollowup = resultFollowup;
	}

	public boolean isDisplayResultAverage() {
		return displayResultAverage;
	}

	public void setDisplayResultAverage(boolean displayResultAverage) {
		this.displayResultAverage = displayResultAverage;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Survey other = (Survey) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder(super.toString());
		if (name == null) {
			
		} else if (type == null) {
			
		} else {
			sb = new StringBuilder(name);
			sb.append(", Category: ");
			sb.append(categoryId);
//			sb.append(", Type: {");
//			boolean first = true;
//			for (String type : types) {
//				if (first) {
//					first = false; 
//				} else {
//					sb.append(",");
//				}
//				sb.append(type);
//			}
//			sb.append("}");
			sb.append(", hierarchyItemId: ");
			sb.append(hierarchyItemId);
			
		}
		return sb.toString();

	}
	
}
